#ifndef __LOG_MGR_H__
#define __LOG_MGR_H__
#include "logger.h"
#include <map>
#include <vector>
#include "singleton_t.h"

class CLogMgr
{
	public:
		typedef enum
		{
			CONN 	= 0x01,
			ERROR 	= 0x02,
			STAT	= 0x03,
			PKG		= 0x04,
			PKG_HEX = 0x05,
		}LOG_TYPE;
	public:
		CLogMgr();
		~CLogMgr();
	public:
		bool Init();
		CLogger& GetLogger(LOG_TYPE enType);
	private:
		bool	m_bInit;
		std::map<LOG_TYPE, CLogger*> m_mapLogger;
};

#define LOG_MGR CSingletonT<CLogMgr>::Instance()

extern bool g_bDebug;

#define CONN(XX, ...) do{ if(g_bDebug) LOG_MGR->GetLogger(CLogMgr::CONN).Log(XX, ##__VA_ARGS__); }while(0)
#define PKG(XX, ...) do{ if(g_bDebug) LOG_MGR->GetLogger(CLogMgr::PKG).Log(XX, ##__VA_ARGS__);}while(0)
#define ERROR(XX, ...) LOG_MGR->GetLogger(CLogMgr::ERROR).Log(XX, ##__VA_ARGS__)
#define STAT(XX, ...) LOG_MGR->GetLogger(CLogMgr::STAT).Log(XX, ##__VA_ARGS__)
#define PKG_HEX(XX, YY) do{ if(g_bDebug) LOG_MGR->GetLogger(CLogMgr::PKG_HEX).Log2Hex(XX, YY);}while(0)

#define CONN_ERROR(XX, ...) do{ \
	if(g_bDebug) LOG_MGR->GetLogger(CLogMgr::CONN).Log(XX, ##__VA_ARGS__);   \
	LOG_MGR->GetLogger(CLogMgr::ERROR).Log(XX, ##__VA_ARGS__);  \
}while(0)

#define PKG_ERROR(XX, ...) do{ \
	if(g_bDebug) LOG_MGR->GetLogger(CLogMgr::PKG).Log(XX, ##__VA_ARGS__);  \
	LOG_MGR->GetLogger(CLogMgr::ERROR).Log(XX, ##__VA_ARGS__); \
}while(0)

#endif
